package com.tim.arc.groovy.base

/**条件语句*/
def score=90;

def level(int val){
    if(val>90){
        return 'perfect';
    }else if(val>80){
        return 'good'
    }else if(val>60){
        return 'ok'
    }else{
        return 'not good'
    }
}

println(level(score));

/*switch；多种匹配方式*/
def level2={
    x->int num=x/10;
        switch (num){
            case 1..5:
                return 'not good'
            case [6,7]:
                return 'ok'
            case 8:
            case 9:
                return 'good'
            case 10:
                return 'perfect'
            default:
                'error'

        }
}

println(level2(30));
println(level2(301));

/*for循环*/
def printAll={
    arrs->for(item in arrs){
        println(item);
    }
}

printAll([1,'2', "3"])